package com.array_list.test;

import java.util.ArrayList;
import java.util.StringJoiner;

public class demo1 {
    public static void main(String[] args) {
        ArrayList<String> arrayList=new ArrayList<>();
        arrayList.add("monday");
        arrayList.add("tuesday");
        arrayList.add("friday");
        arrayList.add("sunday");
//        System.out.println(arrayList);
//        StringJoiner sj=new StringJoiner(",","[","]");
        extracted(arrayList);
    }

    private static void extracted(ArrayList<String> arrayList) {
        System.out.print("[");
        for (int i = 0; i < arrayList.size(); i++) {
            if (i== arrayList.size()-1){
                System.out.print(arrayList.get(i));
                break;
            }
            System.out.print(arrayList.get(i)+",");
        }
        System.out.println("]");
    }
}
